package com.tianji.promotion.mapper;

import com.tianji.promotion.domain.po.Coupon;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 优惠券的规则信息 Mapper 接口
 * </p>
 *
 * @author xzh
 * @since 2024-03-20
 */
public interface CouponMapper extends BaseMapper<Coupon> {

    /**
     * 修改已发行优惠券数量通过id  添加乐观锁
     * @param id
     */
    @Update("update coupon set issue_num=issue_num+1 where id=#{id} and issue_num<total_num")
    int updateIssuseNumById(@Param("id") Long id);
}
